import React from 'react'
import _ from 'underscore'
import format from 'lib/util/format'
import GridWidget from 'lib/components/GridWidget.jsx'
import moment from 'moment'
import numeral from 'numeral'

export default class ActiveUserGrid extends GridWidget {
  constructor(props){
    super(props)
  }
}
ActiveUserGrid.defaultProps = _.extend({}, GridWidget.defaultProps, {
  extraClassName: 'table-layout',
  oddColor: true,
  cols: [
    {
      title: '日期',
      key: 'date',
      // sortable: true,
      render: function (fmtVal,rowData) {
        return this.props.formatType === 'daily'
          ? moment(rowData.startTime).format('YYYY-MM-DD')
          : moment(rowData.startTime).format('YYYY-MM-DD') + ' ~ ' + moment(rowData.endTime).subtract(1, 'days').format('YYYY-MM-DD');
      }
    }, {
      title: '活跃用户',
      key: 'val'
    }, {
      title: '活跃用户占比',
      key: 'rate',
      // sortable: true,
      formatter: (v) => {
        return v !== undefined ? numeral(v).format('0.00%') : '--';
      }
    }
  ]
})
